<admintpl file="header"/>
</head>
<body>
<div class="wrap">
    <form method="post" class="form-horizontal " id="myform1" action="{:U('Admin/LiveChannel/edit_operator_post')}">                
         <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">推流业务员</label>
            <div class="span3">
            	<input type="hidden" name="channel_id" id="channel_id" value="{$channel_id}">
                <input type="text"  style="width: 556px;" name="operatorNames" id="operatorNames" readonly="readonly" value="">
            </div>
        </div>
        
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;"></label>
            <div class="span8">
                <foreach name="operatorList" item="vo">
                    <label style="width: 90px;float:left;">
                    	<input name="operator_checbox" data-name="{$vo.real_name}" type="checkbox" value="{$vo.operator_id}" <if condition="$vo.selected eq 1">checked</if> />{$vo.real_name}
                    </label>
                </foreach>
            </div>
        </div>
        
        <div class="form-actions" style="padding-left:260px;">
            <a class="btn btn-primary" id="ajaxform">提 交</a>
            &nbsp;&nbsp;<a class="btn" id="ajaxback">{:L('BACK')}</a>
        </div>
    </form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/content_addtop.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript"
        src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.10.0/jquery.validate.min.js"></script>
<script src="__PUBLIC__/js/layer/layer.js"></script>
<script>

// ajax 提交表单
$(document).ready(function(){
	function setOperatorNames(){
		var a = [];
		$("input[name='operator_checbox']:checked").each(function(){
			a.push($(this).attr('data-name'));
		});
		$('#operatorNames').val(a.join(','));
	}
	
	function getOperatorIds(){
		var a = [];
		$("input[name='operator_checbox']:checked").each(function(){
			a.push($(this).val());
		});
		return a.join(',');
	}
	
	$("input[name='operator_checbox']").click(function(){
		setOperatorNames();
	});
	
    $("#ajaxform").click(function(){    // 提交按钮触发事件
        var url = $("#myform1").attr("action");    // 获取 表单的 提交地址
        var channel_id = $("#channel_id").val();
        var operatorIds = getOperatorIds();
        if('' == operatorIds){
        	layer.msg('请选择推流业务员！');
			 return;
        }
        $.post(url, {operatorIds:operatorIds, channel_id:channel_id}, function(result){
        	if(result.status == '1'){
        		var msg = '修改成功';
        		setTimeout(function(){
        			var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
        			parent.layer.close(index);
        		}, 1000);
        	}else{
        		var msg = '修改失败';
        	}
        	
    		parent.layer.msg(msg,{time:1000},1,function(a){
        		
    		});
    		
          });
    });
    $("#ajaxback").click(function(){
    	var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
		parent.layer.close(index);
    });
    setOperatorNames();
});
</script>
</body>
</html>